import csv,json,logging,pytest,yagmail,os
import pandas as pd
import yaml
from pathlib import Path
def read_yaml():
    with open('.\\Data\\data.yaml','r',encoding='utf-8') as f:
        return yaml.safe_load(f)

def read_csv(file):
    data=[]
    with open(file,'r',encoding='utf-8-sig') as f:
        reader=csv.DictReader(f)
        for row in reader:
            data.append(row)
    return data

def read_json(file):
    with open(file,'r',encoding='utf-8') as f:
        return json.load(f)

def read_excel(file):
    return pd.read_excel(file,engine='openpyxl').to_dict('records')





# 日志
def log():
    logging.basicConfig(
        filename='./Log/a3mall.log',
        filemode='w+',
        level=logging.DEBUG,
        format='%(message)s' '%(levelname)s' '%(asctime)s' '%(filename)s' '%(lineno)d'
    )
# 邮件
def youjian(file):
    mail=yagmail.SMTP(user='2018675435@qq.com',password='nnqakcckuzyqfebd',host='smtp.qq.com')
    mail.send(to='2018675435@qq.com',subject='a3mall接口自动化',contents='Auto框架部署',attachments=file)
    return mail
# allure报告
def allure():
    pytest.main(['-s',r'D:\Gao6x\Auto_Wms\Api_A3mall\Case\test_case.py','--alluredir=.report','--clean-alluredir'])
    os.system('allure generate .report -o report --clean')









